package com.portal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.portal.entity.Solution;
import com.portal.mapper.SolutionMapper;
import com.portal.service.SolutionService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 解决方案服务实现类
 */
@Service
public class SolutionServiceImpl extends ServiceImpl<SolutionMapper, Solution> implements SolutionService {
    
    @Override
    public List<Solution> getEnabledSolutions() {
        LambdaQueryWrapper<Solution> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Solution::getEnabled, true)
               .orderByAsc(Solution::getSort);
        return list(wrapper);
    }

    @Override
    public Solution getVdiSolution() {
        LambdaQueryWrapper<Solution> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Solution::getEnabled, true)
               .eq(Solution::getType, "VDI")
               .last("LIMIT 1");
        return getOne(wrapper);
    }

    @Override
    public Solution getLlmSolution() {
        LambdaQueryWrapper<Solution> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Solution::getEnabled, true)
               .eq(Solution::getType, "LLM")
               .last("LIMIT 1");
        return getOne(wrapper);
    }

    @Override
    public List<String> getCategories() {
        LambdaQueryWrapper<Solution> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Solution::getEnabled, true)
               .select(Solution::getType)
               .groupBy(Solution::getType);
        return list(wrapper).stream()
                          .map(Solution::getType)
                          .collect(Collectors.toList());
    }
} 